<?php

//$con = mysql_connect("123.58.217.137", "114chuhai_com", "DcRsYHY5mEeLnfZK");
//$con = mysqli_connect("123.58.217.137", "114chuhai_com", "DcRsYHY5mEeLnfZK", '114chuhai_com');

   
  $mysqli =new mysqli("123.58.217.137", "114chuhai_com", "DcRsYHY5mEeLnfZK", '114chuhai_com'); //实例化一个mysqli对象,并打开一个连接
   
  if (mysqli_connect_errno()) { //检查是否可以正确打开数据库
      echo "<font color='red'>unable to connect!</font>";
  }
   
  $continent_id=7;
  $SQL_SELECT_SYMBOLS="SELECT * FROM  wp_terms where continent_id=$continent_id";
   
  if ($result=$mysqli->query($SQL_SELECT_SYMBOLS)) {
      if ($result->num_rows>0) {
          //echo '<table cellpadding="10" border="1">';
          //echo '<tr><th>id</th><th>country</th><th>animal</th><th>cname</th></tr>';
          while ($arr=$result->fetch_array()) {
              $term_id=$arr['term_id'];
              $cname=$arr['cname'];
              $name=str_replace("'", "", $arr['name']);
              $country_code=$arr['country_code'];
              //$str.="INSERT INTO wp_terms (cid, name,slug,country_code) VALUES ('$id', '$cname','$name','$country_code');"."\r\n";
              $str.="INSERT INTO `wp_term_taxonomy` (term_id,taxonomy,parent) VALUES ('$term_id', 'favorites',173);"."\r\n";
              // 'INSERT INTO wp_terms (cid, name,slug,country_code) VALUES ('$id', '$cname','$name','$country_code);"."\r\n";
          }
          echo $str;
      // echo "</table>";
      } else {
          echo "记录未找到!";
      }
   
      $result->close(); //释放记录集所占用的内存
  } else {
      echo "error in query:$query.".$mysqli->error;
  }
  $mysqli->close(); //关闭数据库连接
